home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST7-12.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  766b  |  31 lines

  1. ;
  2. ; *** Listing 7-12 ***
  3. ;
  4. ; Adds up the elements of a byte-sized array using
  5. ; base-only addressing inside the loop, and using
  6. ; an immediate operand with ADC.
  7. ;
  8.     jmp    Skip
  9. ;
  10. ARRAY_LENGTH    equ    1000
  11. TestArray    db    ARRAY_LENGTH dup (1)
  12. TEST_START_OFFSET equ    200    ;we'll add elements 200-299
  13. TEST_LENGTH    equ    100    ; of TestArray
  14. ;
  15. Skip:
  16.     call    ZTimerOn
  17.     mov    bx,offset TestArray+TEST_START_OFFSET
  18.                 ;build the array start
  19.                 ; offset right into the
  20.                 ; base so we can use
  21.                 ; base+index addressing,
  22.                 ; with no displacement
  23.     sub    ax,ax        ;initialize sum
  24.     mov    cx,TEST_LENGTH    ;# of bytes to add
  25. SumArrayLoop:
  26.     add    al,[bx]        ;add in the next byte
  27.     adc    ah,0        ; to the 16-bit sum
  28.     inc    bx        ;point to next byte 
  29.     loop    SumArrayLoop
  30.     call    ZTimerOff
  31.